<template>
  <!-- 放置一个图标 -->
  <div>
    <svg-icon :icon-class="isscreenfull?'exit-fullscreen':'fullscreen'" class="fullscreen" @click="toggleScreen" />
  </div>
</template>

<script>
import screenfull from 'screenfull'
export default {
  name: 'ScreenFull',
  data() {
    return {
      isscreenfull: false
    }
  },
  mounted() {
    // 切换图标状态
    screenfull.on('change', () => {
      this.isscreenfull = screenfull.isFullscreen
    })
  },
  methods: {
    // 点击全屏
    toggleScreen() {
      screenfull.toggle()
    }

  }
}
</script>
